package com.education.wisdom.service.impl;

import com.education.common.utils.Convert;
import com.education.wisdom.mapper.MsMessageMapper;
import com.education.wisdom.pojo.MsMessage;
import com.education.wisdom.service.MsMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 公告 服务层实现
 *
 * @author ruoyi
 * @date 2018-12-13
 */
@Service
public class MsMessageServiceImpl implements MsMessageService {
    @Autowired
    private MsMessageMapper messageMapper;

    /**
     * 查询公告信息
     *
     * @param id 公告ID
     * @return 公告信息
     */
    @Override
    public MsMessage selectMessageById(Integer id) {
        return messageMapper.selectMessageById(id);
    }

    /**
     * 查询公告列表
     *
     * @param message 公告信息
     * @return 公告集合
     */
    @Override
    public List<MsMessage> selectMessageList(MsMessage message) {
        return messageMapper.selectMessageList(message);
    }

    /**
     * 新增公告
     *
     * @param message 公告信息
     * @return 结果
     */
    @Override
    public int insertMessage(MsMessage message) {
        message.setCreatetime(new Date());
        return messageMapper.insertMessage(message);
    }

    /**
     * 修改公告
     *
     * @param message 公告信息
     * @return 结果
     */
    @Override
    public int updateMessage(MsMessage message) {
        return messageMapper.updateMessage(message);
    }

    /**
     * 删除公告对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMessageByIds(String ids) {
        return messageMapper.deleteMessageByIds(Convert.toStrArray(ids));
    }

    @Override
    public List<MsMessage> selectByUserId(String userId) {
        return messageMapper.selectByUserId(userId);
    }

    @Override
    public List<MsMessage> selectViewList() {
        return messageMapper.selectViewList();
    }

}
